﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Reviewer.Entities.Services;
using Reviewer.Business;
using Reviewer.Entities;
using System.Globalization;
using System.Text.RegularExpressions;

public partial class CMSV2_FrontPageTopList : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            using (IFrontPageTopService service = ServiceFactory.FrontPageTopService)
            {
                foreach (FrontPageTop item in service.Find(-1).OrderBy(t => t.Title))
                {
                    this.uiBlTopPosts.Items.Add(
                        new ListItem(
                            String.Format(
                                CultureInfo.InvariantCulture
                                , "{0} - {1}"
                                , item.Title
                                , Regex.Replace(item.Text, @"</?\w+((\s+\w+(\s*=\s*(?:""(.|\n)*?""|'(.|\n)*?'|[^'"">\s]+))?)+\s*|\s*)/?>", ""))
                            , "FrontPageTopManager.aspx?Id=" + item.Id.ToString())
                        );
                }
            }
        }
    }
}
